<!--
 * @Description:
 * @Author: cgt
 * @Date: 2021-12-23 14:05:56
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 19:57:23
-->
<template>
    <div>
        <el-button @click="distance">距离</el-button>
        <el-button @click="area">面积</el-button>
        <el-divider></el-divider>
        <el-button @click="calcDistance">计算距离</el-button>
        <el-button @click="calcArea">计算面积</el-button>
        <el-divider></el-divider>
        <el-button @click="reset">清空</el-button>
    </div>
</template>

<script>
import mixins from '../mixins';
export default {
  name: 'MeasureTool',
  props: {
    getTool: {
      type: Function,
      required: true
    }
  },
  mixins: [mixins],
  data() {
    return {};
  },
  methods: {
    distance() {
      this.getTool('MeasureTool').distance();
    },
    area() {
      this.getTool('MeasureTool').area();
    },
    calcDistance() {
      var distance = this.getTool('MeasureTool').calcDistance(turf.randomLineString().features[0].geometry);
      console.log('distance', distance);
    },
    calcArea() {
      var area = this.getTool('MeasureTool').calcArea(turf.randomPolygon().features[0].geometry);
      console.log('area', area);
    },
    reset() {
      this.getTool('MeasureTool').reset();
    }
  }
};
</script>

<style scoped></style>
